@extends('admin.base')
@section('title', '素材库')
@section('content')

@section('content')
    <div id="main">
        <div class="layui-card">
            <fieldset class="layui-elem-field">
                <div class="layui-field-box">
                    <span class="layui-breadcrumb">
                      <a href="/admin/home">首页</a>
                      <a href="/admin/shop/index?page=@if($request->page){{$request->page}}@else 1 @endif&keywords={{$request->keywords}}&label={{$request['label']}}&type={{$request['type']}}&brand={{$request['brand']}}&state={{$request['state']}}&sell={{$request['state']}}&sell={{$request['sell']}}&title={{$request->title}}&sort={{$request->sort}}">商品列表</a>
                      <a href="">{{$gname}} - 素材库</a>
                    </span>
                    <span class="pull-right">
                        <button class="layui-btn layui-btn-sm"
                                onclick="active('{{url('admin/shop/source_add')}}',{{$id}},'添加','800px','600px');">
                            <i class="layui-icon">&#xe608;</i> 添加
                        </button>
                    </span>
                </div>
            </fieldset>

            <div class="layui-tab layui-tab-card">
                <ul class="layui-tab-title">
                    <li class="layui-this" id="one">图文</li>
                    <li id="two">视频</li>
                    <li id="three">问答</li>
                </ul>
                <div class="layui-tab-content" style="height: 680px;">
                    <div class="layui-tab-item layui-show" id="one_s">
                        <table class="layui-table" lay-even lay-size="">
                            <colgroup>
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                            </colgroup>

                            <thead>
                            <tr>
                                <th class="tc">ID</th>
                                {{--<th class="tc">封面图</th>--}}
                                {{--<th class="tc">其余图片</th>--}}
                                {{--<th class="tc">标题</th>--}}
                                <th class="tc">详情</th>
                                <th class="tc">添加时间</th>
                                <th class="tc">操作</th>
                            </tr>
                            <tbody>
                            @if($list_pic->isEmpty())
                                <tr>
                                    <td colspan="7" style="text-align: center;">暂无数据</td>
                                </tr>
                            @else
                                @foreach ($list_pic as $v)
                                    <tr>
                                        <td class="tc">{{ $v['id'] }}</td>
                                        {{--<td class="tc"><img src="{{$v['picname']}}"></td>--}}
                                        {{--<td class="tc"><a href="/admin/shop/source_other?id={{$v['id']}}&page={{$request->page}}&keywords={{$request->keywords}}">查看</a></td>--}}
{{--                                        <td class="tc">{{ $v['title'] }}</td>--}}
                                        <td class="tc">{{$v['content']}}</td>
                                        <td class="tc">{{$v['created_at']}}</td>
                                        <td class="tc">
                                            <div class="layui-btn-group" >
                                                <button class="layui-btn layui-btn-sm layui-btn" onclick="active('{{url('admin/shop/source_edit?page='.$request->page.'&keywords='.$request->keywords.'&label='.$request->label.'&type='.$request->type.'&brand='.$request->brand.'&state='.$request->state.'&sell='.$request->sell.'&sort='.$request->sort.'&title='.$request->title.'&month='.$request->month)}}','{{$v['id']}}','编辑','800px','600px')">编辑</button>
                                                <button class="layui-btn layui-btn-sm layui-btn-danger" onclick="del('{{url('admin/shop/source_del')}}','{{$v['id']}}');" >删除</button>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                            </tbody>
                            </thead>
                        </table>
                    </div>
                    <div class="layui-tab-item" id="two_s">
                        <table class="layui-table" lay-even lay-size="">
                            <colgroup>
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                            </colgroup>

                            <thead>
                            <tr>
                                <th class="tc">ID</th>
                                <th class="tc">封面图</th>
                                <th class="tc">视频链接</th>
                                <th class="tc">下载量</th>
                                <th class="tc">添加时间</th>
                                <th class="tc">操作</th>
                            </tr>
                            <tbody>
                            @if($list_vedio->isEmpty())
                                <tr>
                                    <td colspan="6" style="text-align: center;">暂无数据</td>
                                </tr>
                            @else
                                @foreach ($list_vedio as $v)
                                    <tr>
                                        <td class="tc">{{ $v['id'] }}</td>
                                        <td class="tc"><img src="{{$v['picname']}}"></td>
                                        <td class="tc"><a target="_blank" href="<?php echo "http://".$_SERVER['HTTP_HOST'];?>{{$v['vedio']}}"><?php echo "http://".$_SERVER['HTTP_HOST'];?>{{$v['vedio']}}</a></td>
                                        <td class="tc">{{$v['click']}}</td>
                                        <td class="tc">{{$v['created_at']}}</td>
                                        <td class="tc">
                                            <div class="layui-btn-group" >
                                                <button class="layui-btn layui-btn-sm layui-btn-danger" onclick="del('{{url('admin/shop/source_del')}}','{{$v['id']}}');" >删除</button>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                            </tbody>
                            </thead>
                        </table>
                    </div>
                    <div class="layui-tab-item" id="three_s">
                        <table class="layui-table" lay-even lay-size="">
                            <colgroup>
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                                <col width="">
                            </colgroup>

                            <thead>
                            <tr>
                                <th class="tc">ID</th>
                                <th class="tc">问题</th>
                                <th class="tc">答案</th>
                                <th class="tc">添加时间</th>
                                <th class="tc">操作</th>
                            </tr>
                            <tbody>
                            @if(count($qanda) <= 0)
                                <tr>
                                    <td colspan="5" style="text-align: center;">暂无数据</td>
                                </tr>
                            @else
                                @foreach ($qanda as $v)
                                    <tr>
                                        <td class="tc">{{ $v['id'] }}</td>
                                        <td class="tc">{{$v['question']}}</td>
                                        <td class="tc">{{$v['answer']}}</td>
                                        <td class="tc">{{$v['created_at']}}</td>
                                        <td class="tc">
                                            <div class="layui-btn-group" >
                                                <button class="layui-btn layui-btn-sm layui-btn" onclick="active('{{url('admin/shop/edit_q?page='.$request->page.'&keywords='.$request->keywords.'&label='.$request->label.'&type='.$request->type.'&brand='.$request->brand.'&state='.$request->state.'&sell='.$request->sell.'&sort='.$request->sort.'&title='.$request->title.'&month='.$request->month)}}','{{$v['id']}}','编辑','800px','600px')">编辑</button>
                                                <button class="layui-btn layui-btn-sm layui-btn-danger" onclick="del('{{url('admin/shop/delete_qanda')}}','{{$v['id']}}');" >删除</button>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                            @endif
                            </tbody>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script>
        $(function(){
            var type = {{$type}};

            if(type == 1){
                $("#one").addClass('layui-this');
                $("#two").removeClass('layui-this');
                $("#three").removeClass('layui-this');
                $("#one_s").addClass('layui-show');
                $("#two_s").removeClass('layui-show');
                $("#three_s").removeClass('layui-show');
            }else if(type == 2){
                $("#one").removeClass('layui-this');
                $("#two").addClass('layui-this');
                $("#three").removeClass('layui-this');
                $("#one_s").removeClass('layui-show');
                $("#two_s").addClass('layui-show');
                $("#three_s").removeClass('layui-show');
            }else{
                $("#one").removeClass('layui-this');
                $("#two").removeClass('layui-this');
                $("#three").addClass('layui-this');
                $("#one_s").removeClass('layui-show');
                $("#two_s").removeClass('layui-show');
                $("#three_s").addClass('layui-show');
            }
        })
    </script>
@endsection